< previous page page_169 next page >

Page 169
0169-01.jpg
Figure 6.1
Program LoadImg uses the LoadImage API function to
resize images while reducing aliasing.
in its FileList control. For each file, the program uses LoadPicture to load the file into a hidden picture box.
The program then checks the file's extension. If the file has a bmp extension, the program uses the LoadImage API function to load the file into a thumbnail picture box. If the file is not a bitmap, the program uses the PaintPicture method to copy the image at a reduced size into the thumbnail picture box.
The Thumbs program is useful for managing directories full of graphic files. One other way the program helps is by allowing you to delete a file. If you click on a thumbnail and press the Delete key, the program moves the file into the system's wastebasket.
SavePicture Routine
Visual Basic's SavePicture routine saves a picture into a bitmap file. For example, the following code saves the picture displayed by the picture box picPerson into the file ''Person.bmp."
e10a6a0a59f035e870d90cca05b85fce.gif
SavePicture picPerson.Picture, "Person.bmp"
SavePicture saves images using the same format in which the image was loaded. For example, if you use LoadPicture to load an icon (.ico) file, SavePicture saves the picture as an icon format file. Pictures saved from an Image property are always saved in bitmap (.bmp) format.
While you can make SavePicture use any filename you like, giving image files the appropriate extensions is less confusing. Naming a bitmap format file "Stars.ico" is misleading. While the LoadPicture function will still load this file correctly, other software may not. If you tell CorelDRAW! to import a bitmap but then select a file formatted as an icon file, you will see an error message indicating that the file has an incorrect bitmap format.

 
< previous page page_169 next page >